import 'package:flutter/material.dart';

class ListController<E> extends ChangeNotifier {
  int activeIndex = 0;

  List<E> _list = [];

  List<E> get list => _list;

  final Future<List<E>> Function() loadCallBack;

  ListController({required this.loadCallBack});

  refresh() async {
    List<E> value = await loadCallBack();
    _list = value;
    notifyListeners();
  }

  load() async {
    List<E> value = await loadCallBack();
    _list = value;
    notifyListeners();
  }

  itemClick(int index) {
    activeIndex = index;
    notifyListeners();
  }
}


// typedef LoadCallBack<E> = List<E> Function();
